<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
    <caption>个人信息</caption>
    <tr>
        <td>照片:</td>
        <td><img :src="p.url" style="width: 100px" alt=""></td>
    </tr>
    <tr>
        <td>名字:</td>
        <td>{{p.name}}</td>
    </tr>
    <tr>
        <td>年龄:</td>
        <td>{{p.age}}</td>
    </tr>
    <tr>
        <td>好友们:</td>
        <td>
            <ul style="list-style-type: none">
                <li v-for="name in p.friends">{{name}}</li>
            </ul>
        </td>
    </tr>
    </table>
        <input type="button" value="请求数据" @click="f()">
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el: "div",//管理页面的div
        data: {
            p:{name:"xxx",age:0,url:"head.jpg",friends:["xxx","xxx"]}

        },
        methods:{
            f(){
                let person = {name:"刘德华",age:50,url:"c.jpg",friends: ["张学友","周星驰"]};
                //把模拟从服务器得到的数据赋值给和页面绑定的p变量 页面会自动发生改变
                v.p=person;
            }
        }
    })
</script>
</body>
</html>